import Main from '@/views/Main.vue';

// 不作为Main组件的子页面展示的页面单独写，如下
export const loginRouter = {
    path: '/login',
    name: 'login',
    meta: {
        title: 'Login - 登录'
    },
    component: () => import('@/views/login.vue')
};

export const page404 = {
    path: '/*',
    name: 'error-404',
    meta: {
        title: '404-页面不存在'
    },
    component: () => import('@/views/error-page/404.vue')
};

export const page403 = {
    path: '/403',
    meta: {
        title: '403-权限不足'
    },
    name: 'error-403',
    component: () => import('@//views/error-page/403.vue')
};

export const page500 = {
    path: '/500',
    meta: {
        title: '500-服务端错误'
    },
    name: 'error-500',
    component: () => import('@/views/error-page/500.vue')
};

export const preview = {
    path: '/preview',
    name: 'preview',
    component: () => import('@/views/form/article-publish/preview.vue')
};

export const locking = {
    path: '/locking',
    name: 'locking',
    component: () => import('@/views/main-components/lockscreen/components/locking-page.vue')
};

// 作为Main组件的子页面展示但是不在左侧菜单显示的路由写在otherRouter里
export const otherRouter = {
    path: '/',
    name: 'otherRouter',
    redirect: '/ad/list',
    component: Main,
    children: [
        {path: 'home', title: {i18n: 'home'}, name: 'home_index', component: () => import('@/views/home/home.vue')},
        {
            path: 'ad/create_ad/',
            title: '添加广告',
            name: 'ad_create',
            component: () => import('@/views/ad-manage/ad-handle/create_ad.vue')
        },
        {
            path: 'ad/set_ad/:id',
            title: '编辑广告',
            name: 'ad_update',
            component: () => import('@/views/ad-manage/ad-handle/update_ad.vue')
        },

        {
            path: 'ad/detail/:id',
            title: '查看广告详情',
            name: 'ad_detail',
            component: () => import('@/views/ad-manage/ad-handle/check_ad.vue')
        },
        /**---------区域添加------------ */
        {
            path: 'district/add-district',
            title: '区域添加',
            name: 'add-district',
            component: () => import('@/views/district-manage/district-handle/add-district.vue')
        },
        {
            path: 'district/edit-district/:id',
            title: '区域编辑',
            name: 'edit-district',
            component: () => import('@/views/district-manage/district-handle/edit-district.vue')
        },
        {
            path: 'district/check-district/:id',
            title: '查看区域信息',
            name: 'check-district',
            component: () => import('@/views/district-manage/district-handle/check-district.vue')
        },

        /**---------修改密码------------ */
        {
            path: 'passupdate',
            title: '修改登录密码',
            name: 'passupdate',
            component: () => import('@/views/pass.vue')
        },
    ]
};

// 作为Main组件的子页面展示并且在左侧菜单显示的路由写在appRouter里
export const appRouter = [
    {
        path: '/ad',
        icon: 'ios-mic-outline',
        name: 'ad',
        title: '广告管理',
        component: Main,
        children: [
            {
                path: 'list',
                title: '广告列表',
                access: 'adlist',
                icon: 'ios-list-outline',
                name: 'adlist',
                component: () => import('@/views/ad-manage/ad_list.vue')
            }
        ]
    },
    // {
    //     path: '/district',
    //     icon: 'ios-mic-outline',
    //     name: 'district',
    //     title: '区域管理',
    //     component: Main,
    //     children: [
    //         {
    //             path: 'list',
    //             title: '区域列表',
    //             access: 'districtlist',
    //             icon: 'ios-list-outline',
    //             name: 'districtlist',
    //             component: () => import('@/views/district-manage/district-list.vue')
    //         }
    //     ]
    // },
];

// 所有上面定义的路由都要写在下面的routers里
export const routers = [
    loginRouter,
    otherRouter,
    preview,
    locking,
    ...appRouter,
    page500,
    page403,
    page404
];
